import time

import base64
import uuid


def generate_lawyer_uuid():
    return uuid.uuid1()


# openid 加密
def openid_to_uid(openid) -> str:
    base64_id = base64.b64encode(openid.encode())
    return base64_id.decode("utf-8")


# openid 解密
def uid_to_openid(uid) -> str:
    base64_openid = base64.b64decode(uid)
    return base64_openid.decode("utf-8")


def generate_file_name(file_name):
    file_type = file_name.split('.')[-1]
    # 前面是file_type+年月日时分秒
    new_name = time.strftime(file_name + '-%Y%m%d%H%M%S', time.localtime())
    # 加后缀名
    new_name += file_type
    # 返回字符串
    return new_name
